/*
 * ArchPlatform.h
 *
 *  Created on: Jan 13, 2010
 *      Author: artur
 */

#ifndef ARCHPLATFORM_H_
#define ARCHPLATFORM_H_

/*
 *
 */
#include <Object.h>

#include <kiddie/kiddie.h>
#include <sys/types.h>
#include <x86/mach-pc/platform.h>
#include <x86/platform.h>

namespace kernel {

class ArchPlatform: public Object {
public:
	ArchPlatform();
	~ArchPlatform();

	void *_get_data_abort_addr(struct cpu_regs *regs);
	bool _is_mmu_on(void);
	void _switch_mmu(void *);
	void *_get_pagedir();
	void __arch_gdt_set_gate(int vec, u32 base, size_t limit, u8 access, u8 gran);
	void __arch_gdt_init(void);
	void __arch_idt_set_gate(int vec, u_long base, u_short sel, u_char flags);
	void __arch_idt_init(void);
	void __arch_tss_set(uint32_t kstack);
	uint32_t __arch_tss_get(void);
	void __arch_tss_init(void);

protected:
	void _archinit(void);

	/**
	 * Global Segment descriptor
	 */
	struct gdt_entry gdt[NGDTS];
	struct gdt_ptr gp;
	struct idt_entry idt[NIDTS];
	struct idt_ptr idtp;
	/**
	 * Global Task
	 */
	struct tss root_tss;

};

}

#endif /* ARCHPLATFORM_H_ */
